import { create } from 'zustand'
import { devtools } from 'zustand/middleware'

interface AppState {
  theme: 'light' | 'dark'
  language: 'zh' | 'en'
  loading: boolean
  setTheme: (theme: 'light' | 'dark') => void
  setLanguage: (language: 'zh' | 'en') => void
  setLoading: (loading: boolean) => void
}

export const useAppStore = create<AppState>()()
  devtools(
    (set) => ({
      theme: 'light',
      language: 'zh',
      loading: false,
      setTheme: (theme) => set({ theme }),
      setLanguage: (language) => set({ language }),
      setLoading: (loading) => set({ loading })
    }),
    {
      name: 'app-store'
    }
  )